
public class FitResult implements Comparable{
	public Anchor anchor;
	boolean fits;
	int prefSpace;
	Space space;
	Rectangle rect;
	public int dimFits;
	public int edgeContacts;
	public float boundsIncrease;
	public float spaceEfficiency;
	
	public FitResult(Anchor a) {
		anchor = a;
		fits = false;
	}
	
	public float getScore(){
		if(!fits) return Float.POSITIVE_INFINITY;
		return 100 * boundsIncrease + (1 - spaceEfficiency) + dimFits / 2f;
	}

	public int compareTo(Object arg0) {
		float s1 = getScore();
		float s2 = ((FitResult)arg0).getScore();
		if(s1 > s2) return 1;
		if(s2 > s1) return -1;
		return 0;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("FitResult: ");
		sb.append("\nAnchor: ");
		sb.append(anchor.toString());
		sb.append("\nRect: ");
		sb.append(rect.toString());
		sb.append("\nspace: ");
		sb.append(space.toString());
		sb.append("\nFits: ");
		sb.append(fits);
		sb.append(" dimFits: ");
		sb.append(dimFits);
		sb.append(" boundsIncrease ");
		sb.append(boundsIncrease);
		sb.append(" spaceEff: ");
		sb.append(spaceEfficiency);
		return sb.toString();
	}

}
